package com.share.thread.pc;

import java.util.concurrent.BlockingQueue;

/**
 * @desc: 消费者
 * @author:caifan
 * @date:2022/1/28
 */
public class Consumer01 implements Runnable {
    private BlockingQueue<Integer> queue;

    public Consumer01(BlockingQueue<Integer> queue) {
        this.queue = queue;
    }

    @Override
    public void run() {
        while(true) {
            try {
                System.out.println("consume:" + queue.take());
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
